package com.javaee.term.mapper;

import com.javaee.term.data.ConverAnaly;
import com.javaee.term.data.TurnOver;
import com.javaee.term.model.Product;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.BaseMapper;

import java.util.List;

public interface ProductMapper extends BaseMapper<Product> {
    @Select("SELECT product_name label, SUM(contact_detail.product_quantity)*product_price y \n" +
            "FROM `product` LEFT JOIN contact_detail on product.product_id = contact_detail.product_id\n" +
            "WHERE contact_detail.contact_id in \n" +
            "(SELECT contact_id FROM contact)\n" +
            "GROUP BY product.product_id\n" +
            "ORDER BY y DESC\n" )
     List<TurnOver> getAllProductTurnOver();
}